// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
// import VueRouter from 'vue-router'
// import routers from './routers'
import router from './router'
import App from './App'
import ElementUI from 'element-ui';
import VueAMap from 'vue-amap'
import fullscreen  from 'vue-fullscreen'
import 'element-ui/lib/theme-chalk/index.css';
import echarts from "echarts"
import VueAwesomeSwiper from 'vue-awesome-swiper'
import 'swiper/dist/css/swiper.css'
Vue.use(VueAwesomeSwiper)
Vue.use(VueAMap)
Vue.use(fullscreen)
Vue.prototype.$echarts = echarts
VueAMap.initAMapApiLoader({
  key: 'b41243fc12bf0bbe32a9b54641ee7e6e',
  plugin: ['Autocomplete', 'PlaceSearch', 'Scale', 'OverView', 'ToolBar', 'MapType', 'PolyEditor', 'AMap.CircleEditor', 'MarkerClusterer']
})
// Vue.use(VueRouter);
Vue.use(ElementUI);
Vue.config.productionTip = false;

// const router = new VueRouter({
//   mode: 'history',
//   routes: routers
// });

new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
});

var routeList = [];
router.beforeEach((to, from, next) => {
  var index = -1;
  for(var i = 0; i < routeList.length; i++) {
    if(routeList[i].name == to.name) {
      index = i;
      break;
    }
  }
  if (index !== -1) {
  //如果存在路由列表，则把之后的路由都删掉
    routeList.splice(index + 1, routeList.length - index - 1);
  } else if(to.name != '登录'){
    routeList.push({"name":to.name,"path":to.fullPath});
  }
  to.meta.routeList = routeList;
  next()
});
